/*
 *   Copyright (c) 2010 Sonrisa Informatikai Kft. All Rights Reserved.
 * 
 *  This software is the confidential and proprietary information of
 *  Sonrisa Informatikai Kft. ("Confidential Information").
 *  You shall not disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Sonrisa.
 * 
 *  SONRISA MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 *  THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 *  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 *  PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SONRISA SHALL NOT BE LIABLE FOR
 *  ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 *  DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

package com.zh.jbet.web.panels.playergame;

import com.zh.jbet.web.pages.BasePanel;
import javax.swing.tree.TreeModel;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.tree.BaseTree;
import org.apache.wicket.markup.html.tree.LinkTree;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

/**
 *
 * @author sonrisa
 */
public class PlayerGamePanel extends BasePanel {
    private LinkTree ltree;
    public PlayerGamePanel(String id, final IModel<TreeModel> model) {
        super(id, model);
        ltree = new LinkTree("tree", model) {
            @Override
            protected IModel getNodeTextModel(IModel<Object> tmodel) {
                return new PropertyModel(tmodel, "userObject.name");
            }

            @Override
            protected void onNodeLinkClicked(Object onode, BaseTree btree, AjaxRequestTarget target) {
                btree.getTreeState().selectNode(onode, true);
                target.addComponent(getFeedback());
                selectedChanged(target);
            }

        };
        ltree.getTreeState().expandAll();
        ltree.getTreeState().setAllowSelectMultiple(false);
        ltree.getTreeState().selectNode(model.getObject().getRoot(), true);
        add(ltree);
    }

    private void selectedChanged(AjaxRequestTarget target) {
        /*
        editPanel.getDataProvider().getFilterState().setParentId(getSelectedContext().getId());
        if (target != null)
            target.addComponent(editPanel);
         * 
         */
    }

}
